const App = {
    // mixins: [Query],//配置文件，路径/utils/mixins.js
    data() {
        return {
            photo,
            tableData: [],
            showDialog: false,
            page: {
                SQLSerialNumber: 't_news_3',
                PaginationNumber: 1, //页码
                RowAmount: 10,
                Condition: window.btoa(unescape(encodeURIComponent("%%")))
            },
            Total: 0,
            relativePath: '',
        }
    },
    mounted() {
        let ls_URL = window.location.href;
        this.relativePath = ls_URL.substring(ls_URL.lastIndexOf("view"), ls_URL.length);
        this.nodeKey = getQueryObject(ls_URL, "nodeKey");// 获取 nodeKey 参数
        this.page.Condition = window.btoa(unescape(encodeURIComponent("%" + this.nodeKey + "%")));
        this.getList(this.page);
    },
    methods: {
        handleSizeChange(newSize) {
            this.page.PaginationNumber = 1;
            this.page.RowAmount = newSize;
            this.getList(this.page);
        },
        handleCurrentChange(newPage) {
            this.page.PaginationNumber = newPage;
            this.getList(this.page);
        },
        handleEdit(row) {
            window.location.href = '../../news_videos_files/news/add.html?action=Modify&nodeKey=' + row.News_SerialNumber + '&News_Category_SerialNumber=' + row.News_Category_SerialNumber
        },
        handleRemove(data) {
            this.$confirm('该操作将删除此条数据,是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            }).then(() => {
                $.ajax({
                    headers: requestHeaders(),
                    url: `${mh}/generalBusiness/generalQueryByTableNameWithOriginal`,
                    method: "post",
                    data: {
                        Data: 'news',
                        Condition: "News_SerialNumber='" + data.News_SerialNumber + "'"
                    },
                    success: (res) => {
                        if (res.length == 1) {
                            res[0].Row_Status = '1';
                            let lJSONObject_DataSet = new Object();
                            let lJSONObject_Table = new Object();
                            lJSONObject_Table['news'] = res;
                            lJSONObject_DataSet['Modify'] = lJSONObject_Table;
                            let Operation_Main = JSON.stringify(deepClone(lJSONObject_DataSet));
                            lJSONObject_DataSet['Add'] = new Object();
                            lJSONObject_DataSet['Add']['base_operation_log'] = [{
                                Operation_Type: '0',
                                Operation_Path: this.relativePath,
                                Operation_Main,
                                Operation_Interface: "generalSaveByRequestBody",
                                Operation_IP: getIpAddress()
                            }]
                            submitSave(lJSONObject_DataSet, (res) => {
                                if (res.Status == 'success') {
                                    this.$message({
                                        type: 'success',
                                        message: '删除成功'
                                    });
                                    this.getList(this.page);
                                } else {
                                    this.$message({
                                        type: 'error',
                                        message: '删除失败'
                                    });
                                }
                            })
                        } else {
                            this.$message({
                                type: 'error',
                                message: '删除失败'
                            });
                        }

                    },
                    complete: (XMLHttpRequest) => {
                        requestPretreatment(XMLHttpRequest)
                    },
                });
            }).catch(() => { });
        },
        getList(data) {
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/generalBusiness/generalPaginationQueryBySQLSerialNumber`,
                method: "post",
                data,
                success: (res) => {
                    this.Total = res.TotalRows;//总数量
                    this.tableData = res.Rows;
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest)
                }
            })
        },
        goBack() {
            window.history.back();
        },
    },
};

const { createApp } = Vue;
const app = createApp(App);
//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}
const ElMessage = ElementPlus.ElMessage;
app.component('yl-upload', ylUpload);
app.use(ElementPlus, { locale: zhCn });
app.mount("#app");
